<template>
	<view class="park_d">
		<view class="main">
			<view class="title_m">{{data.policy_name}}</view>
			<view class="" style="text-align: right;margin-bottom: 40px;" v-if="data.from">{{data.from}}</view>
			<rich-text :nodes="data.content"></rich-text>
			
			<view class="" style="height: 40px;width: 100%;"></view>
			<view @click="downFile(item.url)" class="fj_div" v-if="data.about_files.length>0" v-for="(item,index) in data.about_files" :key="index">
				附件{{index+1 +' '}}下载 
			</view>
		</view>
		<bottomDetail :data='data' type='7'></bottomDetail>
	</view>
</template>

<script>
	import { policy,gz,ShareAdd,pl }  from '../../utils/api.js'
	import bottomDetail from '@/components/bottomDetail.vue'
	export default {
		data() {
			return {
				data:{about_files:[]},
				plList:[],
				isSc:false,
				id:'',
				bottom_iphone:uni.getStorageSync('bottom')||false
			}
		},
		components:{
			bottomDetail
		},
		onShareTimeline() {
			ShareAdd({identification:this.data.id,type:7,name:this.data.policy_name})
			return {
				title: this.data.policy_name+' | 投资钟祥',
			}
		},
		onShareAppMessage() {
			ShareAdd({identification:this.data.id,type:7,name:this.data.policy_name})
			return {
				title: this.data.policy_name+' | 投资钟祥',
			}
		},
		onLoad(option){
			console.log(1)
			this.id = option.id || option.scene
			this.getD(this.id)
		},
		onShow(){
			// let time = setInterval(()=>{
			// 	if(this.id){
			// 		this.page=1
			// 		this.getPlList()
			// 		clearInterval(time)
			// 	}
			// },100)
		},
		methods: {
			downFile(url){
				if(!url){
					uni.showToast({
						title:'附件数据缺失',
						icon:'none'
					})
					return
				}
				uni.getSystemInfo({
					success: (res) => {
							uni.showLoading({
								title:'下载中'
							})
							uni.downloadFile({
								url: url,
								success: (res) => {
									const path = res.tempFilePath;
									uni.openDocument({
										filePath: path,
										fileType: 'pdf',
										success: (res) => {
											uni.hideLoading()
										},
										fail: (err) => {
											uni.hideLoading()
											uni.showToast({
												title: '打开文件失败',
												icon: 'none',
												duration: 2000
											});
										}
									});
								},
								fail: (err) => {
									console.log(err);
									uni.hideLoading()
									uni.showToast({
										title: '下载文件失败',
										icon: 'none',
										duration: 2000
									});
								}
							});
					}
				});
			},
			open(){
				this.$refs.open.show()
			},
			pl(){
				this.$refs.pl.show()
			},
			showhaibao(){
				this.$refs.haibao.show('https://wqq103910.oss-cn-hangzhou.aliyuncs.com/files/3/2021/05/333.jpg')
			},
			getPlList(){
				pl.getList({identification:this.id,type:7,page:this.page}).then(res=>{
					if(this.page == 1){
						this.plList = res.data.data
					}else{
						this.plList = this.plList.concat(res.data.data) 
					}
					this.isNewRenderDone = true
				})
			},
			toPl(){
				uni.navigateTo({
					url:`/pages/pl/pl?data=` + JSON.stringify({identification:this.data.id,type:7,page:this.page,name:this.data.policy_name})
				})
			},
			changeSc(){
				if(! JSON.parse(uni.getStorageSync('userinfo')).nickname ){
					uni.showModal({
						title:'提示',
						content:'需完成登录授权后方能收藏',
						success: (res) => {
							uni.switchTab({
								url:'/pages/my/my'
							})
						},
					})
					return
				}
				gz.AttendAddOrCancel({identification:this.data.id,type:7,name:this.data.policy_name}).then(res=>{
					if(res.status==1){
						this.isSc=!this.isSc
					}
				})
			},
			getD(id){
				policy.detail({id}).then(res=>{
					this.data = res.data
					console.log(res)
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
.fj_div{
	color: #005ef6;
	text-decoration: underline;
	margin-bottom: 4px;
	&:active{
		color: #519bf6;
	}
}
.main{
	width: 94%;
	margin: 0 auto;
	.title_m{
		padding: 20px 0;
		font-size: 22px;
		font-weight: 800;
	}
}
.h66{
	height: 66px;
}
.bottom{
	position: fixed;
	justify-content: space-around;
	align-items: center;
	bottom: 0;
	width: calc(100% - 20px);
	padding: 0 10px;
	height: 54px;
	background: #FFFFFF;
	display: flex;
	z-index: 100;
	box-shadow: 0px -2px 2px #e7e7e7;
	.btn{
		font-size: 18px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		text-align: center;
		height: 54px;
		line-height: 54px;
		background: linear-gradient(90deg, #FE8E33 0%, #FC5517 100%);
		// border-radius: 23px;
		width: 180px;
	}
	.sc{
		font-size: 12px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		text-align: center;	
		// width: ;
		image{
			width: 24px;
			height: 24px;
		}
	}
}
.park_d{
	width: 100%;
}
.flex{
	display: flex;
	width: calc(100% - 32px);
	margin-left: 16px;
	align-items:flex-end;
	.tx{
		position: relative;
		width: 48px;
		// top: -24px;
		margin-right: 6px;
	}
	.level{
		width: 28px;
		height: 16px;
		font-size: 10px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 16px;
		text-align: center;
		background: #FF2D44;
		border-radius: 3px;
	}
}
.main{
	width: calc(100% - 32px);
	margin: 0 16px 10px;
	.park_name{
		font-size: 18px;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #333333;
		line-height: 24px;
		margin-top: 10px;
	}
	.tip{
		margin-top: 10px;
		height: 20px;
		line-height: 20px;
		padding: 0 3px;
		border-radius: 2px;
		border: 1px solid #FC5517;
		margin-left: 4px;
		display: inline-block;
		font-size: 12px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FC5517;
	}
	.mj{
		display: flex;
		justify-content: space-between;
		margin: 15px 0;
		.mj_l{
			display: flex;
			border-radius: 14px;
			width: 195px;
			height: 28px;
			background: #F3F3F6;
			justify-content: space-between;
			.l_t{
				width: 76px;
				height: 28px;
				line-height: 28px;
				color: #fff;
				font-size: 14px;
				background: linear-gradient(180deg, #FE8E33 0%, #FC5517 100%);
				border-radius: 14px 0px 14px 14px;	
				text-align: center;
			}
			.num{
				width: 120px;
				font-size: 14px;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #666666;
				text-align: center;
				line-height: 28px;
			}
		}
		.mj_r{
			height: 26px;
			line-height: 26px;
			text-align: center;
			background: #FEEEE7;
			border-radius: 14px;
			font-size: 14px;
			font-weight: 400;
			color: #FC5517;
			padding: 0 10px;
		}
	}
	.add{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 10px;
		image{
			width: 14px;
		}
		.add_l{
			font-size: 14px;
			font-weight: 400;
			color: #666666;
			.l_f{
				display: flex;
				align-items: center;
			}
		}
		.add_r{
			display: flex;
			text-align: center;
			justify-content: space-between;
			width: 84px;
			font-size: 12px;
			font-weight: 400;
			color: #FC5517;
		}
	}
}

.title{
	height: 18px;
	font-size: 18px;
	font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 700;
	color: #333333;
	line-height: 18px;
	margin: 40px 20px 20px 20px;
}
.right_c{
	margin-left: 16px;
	.image-container,.swiper-item{
		height: 88px;
	}
	.swiper-item{
		width: 128px !important;
		height: 88px;
		image{
			width: 121px;
			height: 88px;
			border-radius: 4px;
		}
	}
}
.mt20{
	margin-top: 20px;
}
.main1{
	width: calc(100% - 32px);
	margin: 0 16px 10px;
	.top1{
		display: flex;
		margin-bottom: 4px;
		.t_l{
			width: 12px;
			background: #FC5517;
			font-size: 12px;
			font-weight: 400;
			color: #FFFFFF;
			display: flex;
			justify-content: center;
			align-items: center;
			text-align: center;
			padding: 0 10px;
			min-height: 76px;
		}
		.t_r{
			width: calc(100% - 32px);
			.item{
				height: 28px;
				line-height: 28px;
				text-align: center;
				display: flex;
				font-size: 12px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
				view{
					width: 50%;
				}
			}
			.item1{
				height: 76px;
				line-height: 76px;
			} 
			.item:nth-child(odd){
				background: #F0F0F0;
			}
		}
	}
	.orange{
		background: #FFA414 !important;
	}
}
.pl_item{
	display: flex;
	margin: 10px 16px;
	width: calc(100% - 32px);
	.tx{
		width: 24px;
		height: 24px;
		margin-right: 10px;
	}
	.r{
		width: calc(100% - 34px);
		padding-bottom:10px;
		border-bottom: 1px solid #E9EBEE;
		.top{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10px;
			.name{
				font-size: 14px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #507DAF;
			}
			.time{
				font-size: 14px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
			}
		}
		.content{
			padding-top:10px;
			font-size: 16px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
		}
	}
}
.pl{
		display: flex;
		justify-content: space-between;
		margin-left: 16px;
		width: calc(100% - 32px);
		margin-top: 20px;
		.pl_1{
			font-size: 18px;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #333333;
		}
		.pl_2{
			display: flex;
			align-items: center;
			font-size: 14px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FF5100;
			image{
				width: 15px;
				margin-right: 2px;
			}
		}
	}
	
</style>
